package org.adoxx.adows.client; import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; import javax.xml.rpc.holders.IntHolder; import javax.xml.rpc.holders.StringHolder; public class ReadModel { /** * @param args * @throws ServiceException * @throws MalformedURLException * @throws RemoteException */ public static void main(String[] args) throws MalformedURLException, ServiceException, RemoteException { /* * Initialize the client, provide endpoint address of respective ADOWS * service (in the example below ADOWS has been started on port 8181 - * it http://localhost:8181) */ com.boc_eu.adoweb.adows.client.AdoWSStub binding = (com.boc_eu.adoweb.adows.client.AdoWSStub) new com.boc_eu.adoweb.adows.client.AdoWSLocator() .getAdoWS(new URL("http://localhost:8181")); /* * Initialize result holder objects * * errorCode ... returns the errorCode of the AdoScript as documented in * AdoScript section of Development Toolkit Handbook * * result ... String result from running the AdoScript */ IntHolder errorCode = new IntHolder(); StringHolder result = new StringHolder(); /* * Sample implementation of query AdoScript in a static class for re-use * * For this example a model of type "Sample" named "Demonstration" must exist. * The AdoScript sets the result in an AdoScript variable "result" and puts in into the * StringHolder of above */ String script = QueryScripts.getAllInstancesOfModelByName( "8E Model", "Sample", "result"); /* * Execute AdoScript on ADOWS */ binding.execute(script, "result", errorCode, result); /* * Prints the result into System.out * */ printResults(result.value, System.out); } private static void printResults(String value, PrintStream out) { String[] objects = value.split(" "); for (int i = 0; i < objects.length; i++) { out.println("Model contains object with ID: " + objects[i]); } } }